package com.dormms.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.dormms.bean.DormAdminInfo;
import com.dormms.bean.DormLocation;
import com.dormms.dto.DormLocationAdmin;
import com.dormms.dto.DormLocationAdminInfo;
import com.dormms.service.DormLocationService;
import com.dormms.tool.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

@Controller
public class DormLocationController {
	@Autowired
	private DormLocationService dormLocationService;
	
	@RequestMapping("super/queryDormLocationByPageBySuper")
	@ResponseBody
	public PageInfo<DormLocation> queryDormLocationByPageBySuper(Page page, DormLocation dormLocation){
		PageHelper.startPage(page.getCurrPage(), page.getPageSize());
		List<DormLocation> dormLocations = dormLocationService.queryDormLocationInfoByDormLocation(dormLocation);
		PageInfo<DormLocation> pageInfo = new PageInfo<DormLocation>(dormLocations);
		return pageInfo;
	}
	
	@RequestMapping("super/insertDormLocationInfo")
	@ResponseBody
	public Integer insertDormLocationInfo(DormLocation dormLocation) {
		return dormLocationService.insertDormLocationInfo(dormLocation);
	}
	
	@RequestMapping("super/getNoAdminDormLocationDormAdmin")
	@ResponseBody
	public List<DormAdminInfo> getNoAdminDormLocationDormAdmin(){
		return dormLocationService.getNoAdminDormLocationDormAdmin();
	}
	
	@RequestMapping("super/getAllDormLocation")
	@ResponseBody
	public List<DormLocation> getAllDormLocation(){
		DormLocation dormLocation = new DormLocation();
		return dormLocationService.queryDormLocationInfoByDormLocation(dormLocation);
	}
	@RequestMapping("super/insertDormLocationAdminInfo")
	@ResponseBody
	public Integer insertDormLocationAdminInfo(DormLocationAdmin dormLocationAdmin) {
		return dormLocationService.insertDormLocationAdminInfo(dormLocationAdmin);
	}
	@RequestMapping("super/getAdminDormLocationAllDormAdmin")
	@ResponseBody
	public DormLocationAdminInfo getAdminDormLocationAllDormAdmin(Integer dormLocationId) {
		return dormLocationService.getAdminDormLocationAllDormAdmin(dormLocationId);
	}
	@RequestMapping("super/updateDormLocationInfoBySuper")
	@ResponseBody
	public Integer updateDormLocationInfoBySuper(DormLocation dormLocation) {
		return dormLocationService.updateAdminDormLocationInfoBySuper(dormLocation);
	}
	
	@RequestMapping("super/deleteDormLocationAdmin")
	@ResponseBody
	public Integer deleteDormLocationAdmin(String dormAdminId) {
		return dormLocationService.deleteDormLocationAdmin(dormAdminId);
	}
}
